package io.zbc.grow.arithmetic.util;

import io.zbc.grow.arithmetic.business.question.IQuestion;
import io.zbc.grow.arithmetic.business.question.QuestionFactory;
import io.zbc.grow.arithmetic.vo.Binary;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author zbc
 * @date 2022/12/1
 */
@Service
public class QuestionUtil {

    public List<Binary> mixBinaries(int maxValue, int count) {
        List<Binary> binaries = new ArrayList<>();
        QuestionFactory questionFactory = new QuestionFactory();
        IQuestion question;
        for (int i = 0; i < count; i++) {
            question = questionFactory.getQuestion(RandomUtil.getRandom(2));
            binaries.add((Binary) question.generateQuestion(maxValue));
        }
        return binaries;
    }

    public List<Binary> binaries(int questionType, int maxValue, int count) {
        List<Binary> binaries = new ArrayList<>();
        QuestionFactory questionFactory = new QuestionFactory();
        IQuestion question = questionFactory.getQuestion(questionType);
        for (int i = 0; i < count; i++) {
            binaries.add((Binary) question.generateQuestion(maxValue));
        }
        return binaries;
    }

}
